import requests

# 请求地址
url = 'https://www.baidu.com/s'

# 请求头
headers = {
    'User-Agent': 'Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/83.0.4103.116 Safari/537.36 UOS'
}

# 表单数据
form_data = {
    'wd': '李昊哲-小课'
}

# 发送请求 获取服务器响应
# 请求方式：GET POST PUT PATCH DELETE OPTION
response = requests.get(url=url, headers=headers,params=form_data)

# 输出HTTP状态码
# print(response.status_code)
# 输出服务器响应字符串
# print(response.text)
if response.status_code == 200:
    print('正在爬取,请稍等...')
    # 将网页保存
    with open(file='李昊哲.html', mode='w', encoding='utf-8') as f:
        f.write(response.text)
        f.close()
    print('爬取成功')

